-- round_bleed
-- created by dengc
-- 流血状态，值与回合挂钩

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 每回合触发
    trigger = function(who, prop, arg)
        local value = prop[3];

        -- 有效回合
        local round = who.dbase:query("valid_round") or CombatM.getRound();

        -- 开始处于黑暗形态的回合
        local startDarkRound = who.dbase:query("start_dark_round") or 0;

        -- 回合差
        local difRound = round - startDarkRound;

        -- 有效回合加一
        who.dbase:set("valid_round", round + 1);

        -- 最大生命值
        local maxHp = ME.user:getMaxHp();

        -- 最终伤害
        local damage = FormulaM.invoke("CALA_ROUND_BLEED_VALUE", difRound, maxHp, value);

        return CombatM.receiveDamage(who, ME.user, damage, 0);
    end,

    record = function(target, prop, path)
        return false;
    end
};